//
//  ThirdConfig.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/3.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "ThirdConfig.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <WXApi.h>
#import <EMSDK.h>
#import <UserNotifications/UserNotifications.h>
#import "ShareTool.h"

static NSString *appKey = @"722dde5b1dc43834e68da4e7";
static NSString *channel = @"Publish channel";
static BOOL isProduction = FALSE;

@implementation ThirdConfig

+ (void)setThirdConfig:(UIApplication *)application options:(NSDictionary *)launchOptions delegate:(id)delegate
{
    [ShareTool setAppkey];//分享初始化
    
    //微信注册
//    [WXApi registerApp:@"wxb4ba3c02aa476ea1" withDescription:@"funearth"];
    [WXApi registerApp:@"wx637ea06a1c6d1fff"];
    
    
    //环信注册
//    EMOptions *options = [EMOptions optionsWithAppkey:@"comeonsoft#sanitjuli"];
//    [[EMClient sharedClient] initializeSDKWithOptions:options];
//    [AMapLocationTool shareLocation];//申请定位权限
    //极光推送
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
        JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
        entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound;
        [JPUSHService registerForRemoteNotificationConfig:entity delegate:delegate];
    }
    else if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
        //可以添加自定义categories
        [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
                                                          UIUserNotificationTypeSound |
                                                          UIUserNotificationTypeAlert)
                                              categories:nil];
    }
    else {
        //categories 必须为nil
        [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)
                                              categories:nil];
    }
    [JPUSHService setupWithOption:launchOptions appKey:appKey
                          channel:channel
                 apsForProduction:isProduction
            advertisingIdentifier:nil];
    //2.1.9版本新增获取registration id block接口。
    [JPUSHService registrationIDCompletionHandler:^(int resCode, NSString *registrationID) {
        if(resCode == 0){
            NSLog(@"registrationID获取成功：%@",registrationID);
            
        }
        else{
            NSLog(@"registrationID获取失败，code：%d",resCode);
        }
    }];
}

@end
